package com.tanhua.common.utils;

import com.tanhua.common.pojo.User;

/**
 * Created with IntelliJ IDEA.
 *
 * @ClassName: UserThreadLocal
 * @Author:王晨晗
 * @Description: 本地线程类,保存用户信息
 * @Date: 2021/12/30/11:02
 */
public class UserThreadLocal {
    private static final ThreadLocal<User> LOCAL = new ThreadLocal<User>();

    private UserThreadLocal(){

    }

    /**
     * @description 将user信息保存到ThreadLocal中
     * @param user
     * @updateTime 2021/12/30 11:06
     */
    public static void set(User user){
        LOCAL.set(user);
    }

    /**
     * @description 返回当前线程中的user
     * @updateTime 2021/12/30 11:07
     * @return: com.tanhua.common.pojo.User
     */
    public static User get(){
        return LOCAL.get();
    }

    /**
     * @description 删除当前线程中的user
     * @updateTime 2021/12/30 11:08
     */
    public static void remove(){
        LOCAL.remove();
    }
}
